//
//  UIView+Mango.h
//  Mango
//
//  Created by 胡超 on 2017/11/11.
//  Copyright © 2017年 胡超., ltd. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@class MGUIViewBorderLayer;

typedef NS_OPTIONS(NSUInteger,MGBorder) {
    MGBorderTop     = 1 << 0,
    MGBorderBottom  = 1 << 1,
    MGBorderLeft    = 1 << 2,
    MGBorderRight   = 1 << 3,
};

@interface UIView (Mango)

#pragma mark - Frame
@property (nonatomic) CGPoint origin;
@property (nonatomic) CGSize  size;
@property (nonatomic) CGFloat width;
@property (nonatomic) CGFloat height;
@property (nonatomic) CGFloat top;
@property (nonatomic) CGFloat left;
@property (nonatomic) CGFloat bottom;
@property (nonatomic) CGFloat right;
@property (nonatomic) CGFloat centerX;
@property (nonatomic) CGFloat centerY;
@property (nonatomic,readonly) CGPoint boundsCenter;

#pragma mark - Border
/** 单边框*/
@property (nonatomic,readonly,nullable) MGUIViewBorderLayer *borderLayer;
- (void)setBorder:(CGFloat)width color:(UIColor *)color side:(MGBorder)side;
- (void)setDottedBorder:(CGFloat)width color:(UIColor *)color dashPattern:(NSArray*)dashPattern side:(MGBorder)side;
- (void)setBorderHidden:(BOOL)hidden;

- (void)setByRoundingCorners:(UIRectCorner)byRoundingCorners cornerRadius:(CGFloat)cornerRadius;

#pragma mark - Convenience

- (void)removeAllSubviews;
- (void)removeAllSubviewsExcept:(NSArray<UIView *> *)exceptViews;
- (UIImage *)toImage;
- (nullable UIViewController *)viewController;

- (void)setSizeToFitOffset:(CGSize)offset;

#pragma mark - Animation

- (void)addRotateAnimationWithSpeed:(NSTimeInterval)speed;

@end

NS_ASSUME_NONNULL_END
